{% extends "base.html" %}
{% load humanize %}
{% load extended_filter %}

{% block content %}
    <ul class="breadcrumb">
        <li>
            <a href="/monitor/service/{{ cluster.service.id }}">{{ cluster.service.name }}</a> <span
                class="divider">/</span>
        </li>
        <li class="active">{{ cluster.name }}</li>
    </ul>
    <ul class="nav nav-pills">
        <li>
        <a href="/monitor/cluster/{{ cluster.id }}/task/">Tasks</a>
        </li>
        <li class="active">
        <a href="/monitor/cluster/{{ cluster.id }}/user/">Users</a>
        </li>
        <li>
        <a href="/monitor/cluster/{{ cluster.id }}/total/">Total</a>
        </li>
    </ul>
    <table class="table table-striped table-bordered">
        <thead>
        <tr>
            <th>user id</th>
            <th>name quota</th>
            <th>used name</th>
            <th>remaining name</th>
            <th>space quota</th>
            <th>used space</th>
            <th>remaining space</th>
        </tr>
        </thead>
        <tbody>
        {% for dir in dirs %}
            <tr>
                <td>{{ dir.name }}</a></td>
                <td>{{ dir.quota|intcomma }}</td>
                <td>
                  <a href="{{tsdb_url_prefix}}/#start={{quota_start_date}}&m=sum:used_quota{cluster={{cluster.name}},user_id={{dir.name}}}&o=&yrange=[0:]&key=out center top&wxh=1200x600">
                    {{ dir.used_quota|intcomma }}
                  </a>
                </td>
                {% if dir.quota|is_name_quota_healthy:dir.used_quota %}
                <td>{{ dir.remaining_quota|intcomma }}</td>
                {% else %}
                <td class="text-error">{{ dir.remaining_quota|intcomma }}</td>
                {% endif %}
                <td>{{ dir.space_quota|format_bigint }}</td>
                <td>
                  <a href="{{tsdb_url_prefix}}/#start={{quota_start_date}}&m=sum:used_space_quota{cluster={{cluster.name}},user_id={{dir.name}}}&o=&yrange=[0:]&key=out center top&wxh=1200x600">
                  {{ dir.used_space_quota|format_bigint }}
                  </a>
                </td>
                {% if dir.space_quota|is_space_quota_healthy:dir.used_space_quota %}
                <td>{{ dir.remaining_space_quota|format_bigint }}</td>
                {% else %}
                <td class="text-error">{{ dir.remaining_space_quota|format_bigint }}</td>
                {% endif %}
            </tr>
        {% endfor %}
        </tbody>
    </table>
    <div class="row">
    <ul class="nav nav-pills pull-right">
        <li>
        <a href="/monitor/cluster/{{ cluster.id }}/user/?refresh">Refresh</a>
        </li>
    </ul>
    </div>
{% endblock %}
